package com.errol.batchprocessor.batchprocessor.payload;

import com.renjia.entity.AbstractImportBatch;
import com.renjia.service.generic.middleware.batchprocessor.abs.AbstractAdvisorPayload;
import lombok.Getter;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;

import java.util.List;

/**
 * 批处理模型 批次数据载体抽象类
 *
 * @author zhang xiao bin
 * @version v1.0
 * @date 2021/02/22
 * @since v5.0.5
 **/
@Getter
public abstract class AbstractBatchPayload<IE extends AbstractImportBatch, AT extends Enum<?>, BE, SE>
        extends AbstractAdvisorPayload {

    private final long createTime;
    private final String batchNo;
    private final AT advisorTypeEnum;
    private final IE importBatch;
    private final BE batchEntity;
    private final List<SE> singleEntityList;

    public AbstractBatchPayload(@NonNull String batchNo, @NonNull AT advisorTypeEnum, @NonNull IE importBatch, @Nullable BE batchEntity, @NonNull List<SE> singleEntityList) {
        Assert.notNull(batchNo, this.getClass() + " batchNo 不能为空");
        this.createTime = System.currentTimeMillis();
        this.batchNo = batchNo;
        this.advisorTypeEnum = advisorTypeEnum;
        this.importBatch = importBatch;
        this.batchEntity = batchEntity;
        this.singleEntityList = singleEntityList;
    }

}
